package com.geezdata.cps.base.exceptions;

import java.util.Map;

import com.geezdata.cps.base.enums.ErrorCode;
import com.google.common.collect.Maps;

public class BusinessException extends RuntimeException {
	private static final long serialVersionUID = 1L;
	
	private int code;
	private String failedTaskUrl;
	private String url;
	private Map<String, Object> params;
	
	
	public BusinessException(String failedTaskUrl, String url, Map<String, Object> params) {
        super(ErrorCode.INTERNAL_SERVER_ERROR.getDesc());
        this.code = ErrorCode.INTERNAL_SERVER_ERROR.getCode();
        this.url = url;
        this.failedTaskUrl = failedTaskUrl;
        this.params = params;
    }
	
	public BusinessException(String failedTaskUrl, String url, String key, Object value) {
		super(ErrorCode.INTERNAL_SERVER_ERROR.getDesc());
        this.code = ErrorCode.INTERNAL_SERVER_ERROR.getCode();
        this.url = url;
        this.failedTaskUrl = failedTaskUrl;
        this.params = Maps.newHashMap();
        params.put(key, value);
	}
    
    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }
    
    public int getCode() {
        return code;
    }
    
    public void setCode(int code) {
        this.code = code;
    }

	public String getUrl() {
		return url;
	}

	public String getFailedTaskUrl() {
		return failedTaskUrl;
	}

	public void setFailedTaskUrl(String failedTaskUrl) {
		this.failedTaskUrl = failedTaskUrl;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Map<String, Object> getParams() {
		return params;
	}

	public void setParams(Map<String, Object> params) {
		this.params = params;
	}
}
